package com.study.springsecurity.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.study.springsecurity.mapper.ApiInfoMapper;
import com.study.springsecurity.pojo.entity.ApiInfoEntity;
import com.study.springsecurity.pojo.vo.ApiRoleCodeVo;
import com.study.springsecurity.service.ApiInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * api接口信息Service接口实现
 *
 * @Author YL
 * @Create 2024/4/17 0:29
 * @Version 1.0
 */
@Service
public class ApiInfoServiceImpl extends ServiceImpl<ApiInfoMapper, ApiInfoEntity> implements ApiInfoService {

    @Autowired
    private ApiInfoMapper apiInfoMapper;

    @Override
    public Map<String, List<ApiRoleCodeVo>> queryAllApiAndNeedRole() {
        List<ApiRoleCodeVo> apiRoleCodeVos = apiInfoMapper.queryAccessApiNeedRole();
        return apiRoleCodeVos.stream().collect(Collectors.groupingBy(ApiRoleCodeVo::getAuthType));
    }
}
